package com.heima.common.minio;

import io.minio.MinioClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
 * @Description
 * @Author pure
 * @Date DATE D A T E {TIME}
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "minio")
@PropertySource("classpath:minio.properties")
public class MinioConfig {

    private String accessKey;

    private String secretKey;

    private String url;

    @Bean
    public MinioClient minioClient() {
        try {
            return MinioClient.builder().endpoint(url).credentials(accessKey, secretKey).build();
        }catch (Exception e) {
            throw new RuntimeException("初始化MinioClient失败", e);
        }
    }

}